"uniform vec4 gTransform[ 4 ];\n"
"uniform vec4 gWorldMatrix[ 3 ];\n"
"uniform vec4 gInvTransposedWorldMatrix[ 3 ];\n"
"uniform vec4 gDiffuseColor;\n"
"uniform vec3 gAmbient;\n"
"uniform vec4 gLightPosX;\n"
"uniform vec4 gLightPosY;\n"
"uniform vec4 gLightPosZ;\n"
"uniform vec3 gLightColor0;\n"
"uniform vec3 gLightColor1;\n"
"uniform vec3 gLightColor2;\n"
"uniform vec3 gLightColor3;\n"
"attribute vec4 POSITION0;\n"
"attribute vec4 COLOR0;\n" //頂点カラー
"attribute vec2 TEXCOORD0;\n"
"attribute vec3 NORMAL0;\n"
"varying vec4 v_color;\n"
"varying vec2 v_texcoord;\n"
"void main()\n"
"{\n"
"  vec4 pos;\n"
"  pos.x = dot( gTransform[ 0 ], POSITION0 );\n"
"  pos.y = dot( gTransform[ 1 ], POSITION0 );\n"
"  pos.z = dot( gTransform[ 2 ], POSITION0 );\n"
"  pos.w = dot( gTransform[ 3 ], POSITION0 );\n"
"  pos.z = 2.0 * pos.z - pos.w;\n" // OpenGL用調整 0～w → -w～w
"  gl_Position = pos;\n"
"  vec3 wp;\n" //ワールド位置
"  wp.x = dot( gWorldMatrix[ 0 ], POSITION0 );\n"
"  wp.y = dot( gWorldMatrix[ 1 ], POSITION0 );\n"
"  wp.z = dot( gWorldMatrix[ 2 ], POSITION0 );\n"
"  vec3 wn;\n" //ワールド法線
"  wn.x = dot( gInvTransposedWorldMatrix[ 0 ].xyz, NORMAL0 );\n"
"  wn.y = dot( gInvTransposedWorldMatrix[ 1 ].xyz, NORMAL0 );\n"
"  wn.z = dot( gInvTransposedWorldMatrix[ 2 ].xyz, NORMAL0 );\n"
"  vec4 lvX, lvY, lvZ;\n"
"  lvX = gLightPosX - wp.xxxx;\n"
"  lvY = gLightPosY - wp.yyyy;\n"
"  lvZ = gLightPosZ - wp.zzzz;\n"
"  vec4 lvL;\n"
"  lvL = lvX * lvX;\n"
"  lvL += lvY * lvY;\n"
"  lvL += lvZ * lvZ;\n"
"  lvL += 0.00001;\n" //0割り防止
"  vec4 d = lvX * wn.xxxx;\n"
"  d += lvY * wn.yyyy;\n"
"  d += lvZ * wn.zzzz;\n"
"  d /= lvL;\n"
"  d = max( vec4( 0 ), d );\n" //マイナスは0。
"  vec3 c;\n"
"  c = gAmbient.xyz;\n"
"  c += gLightColor0 * d.x;\n"
"  c += gLightColor1 * d.y;\n"
"  c += gLightColor2 * d.z;\n"
"  c += gLightColor3 * d.w;\n"
"  v_color.xyz = c * COLOR0.zyx * gDiffuseColor.xyz;\n" //RGB入れ替え
"  v_color.w = COLOR0.w * gDiffuseColor.w;\n" //頂点アルファも乗算
"  v_texcoord = TEXCOORD0;\n"
"}\n"
